package com.wobito.pojo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * @Author Wangbaba
 * @Date 2024/8/19 9:54
 * @Version 1.0
 */
@Getter
public enum IsDeletedEnum {

    NORMAL(0,"正常"),
    DELETED(1,"删除");

    @EnumValue
    private final int code;

    @JsonValue
    private final String name;

    IsDeletedEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameFromCode(int code){
        IsDeletedEnum isDeletedEnum= Arrays.stream(IsDeletedEnum.values()).filter(d->d.code==code).findFirst().orElseThrow(() -> new IllegalArgumentException("没有找到code: " + code));
        return isDeletedEnum.getName();
    }
}
